import java.awt.*;

// 爆炸效果类
public class Explosion extends GameObject {
    private static final int MAX_FRAMES = 12;
    private int frame;
    
    public Explosion(int x, int y, int width, int height) {
        super(x, y, width, height);
        this.frame = 0;
        
        // 播放爆炸音效
        SoundManager.playSound("explosion.wav");
    }
    
    public void update() {
        frame++;
    }
    
    public void draw(Graphics g) {
        if (frame >= MAX_FRAMES) {
            return;
        }
        
        // 爆炸效果
        int radius = width / 2 * (MAX_FRAMES - frame) / MAX_FRAMES;
        g.setColor(new Color(255, 255 - frame * 20, 0, 255 - frame * 20));
        g.fillOval(x - radius, y - radius, radius * 2, radius * 2);
        
        g.setColor(new Color(255, 0, 0, 255 - frame * 20));
        g.fillOval(x - radius / 2, y - radius / 2, radius, radius);
    }
    
    public boolean isFinished() {
        return frame >= MAX_FRAMES;
    }
}
